home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2005 Utilities / CHIP Utilities 2005.7z / CHIP Utilities 2005.iso / images / freesco.igz / freesco.img / router / rc / rc_diald < prev    next >
Encoding:
Text File  |  2003-06-09  |  1.8 KB  |  90 lines

  1. #!/bin/sh
  2. #
  3. # Generate config, start/stop dialer daemon (gateway - modem0)
  4.  
  5. . /etc/system.cfg
  6. . /etc/colors
  7. . /etc/chat.pwd
  8. . /etc/live.cfg
  9.  
  10. [ "$ROUTER" = dialup ] || exit
  11.  
  12. fn2()    { ps | sed -n '/    diald/P'; }
  13. stp()    {
  14.     [ "`fn2`" ] || return
  15.     echo -n "Stopping diald...            "
  16.     killall diald -15
  17.     killall connect
  18.     sleep 2
  19.     killall connect -9
  20.     =
  21. }
  22. str()   {
  23.     [ "$MTU0" ] && a="mtu $MTU0"
  24.     [ "$MRU0" ] && b="mru $MRU0"
  25.     cat >/etc/ppp/options.$MODEM0<<-EOF
  26.     name    $LOGIN
  27.     EOF
  28.     c="pppd-options noauth"
  29.     [ "$ADRTYPE" = dynamic ] && c="$c noipdefault"
  30.     [ "$USEPEERDNS" != n ] && c="$c usepeerdns"
  31.     [ "$LOGDIALD" = y -o "$BOOTMOD" = debug ] && d="debug 31"
  32.     [ "$LOGPPPD" = y -o "$BOOTMOD" = debug ] && c="$c debug"
  33.     [ "$MODEM" ] && MODEM0=$MODEM
  34.     [ "$RTRCNT" ] && e="retry-count $RTRCNT"
  35.     [ "$DRTRCNT" ] && f="died-retry-count $DRTRCNT"
  36.     [ "$RBKOFF" ] && g="redial-backoff-limit $RBKOFF"
  37.     [ "$DFAILIM" ] && h="dial-fail-limit $DFAILIM"
  38.     [ "$FPTOUT" ] && i="first-packet-timeout $FPTOUT"
  39.     RDTOUT=${RDTOUT:-5}
  40.     cat >/etc/diald.conf <<-EOF
  41.         $DRULES
  42.         device /dev/$MODEM0
  43.         speed $MSPEED0
  44.         $ADRTYPE
  45.         local $LOCAL
  46.         remote $REMOTE
  47.         modem
  48.         crtscts
  49.         $a
  50.         $b
  51.         $c
  52.         $d
  53.         linkname dialup
  54.         mode ppp
  55.         connect /etc/connect
  56.         defaultroute
  57.         redial-timeout $RDTOUT
  58.         $e
  59.         $f
  60.         $g
  61.         $h
  62.         $i
  63.         fifo /etc/diald.ctl
  64.         run-prefix /tmp
  65.         path-route /bin/route
  66.         path-ifconfig /bin/ifconfig
  67.         path-pppd /sbin/pppd
  68.     EOF
  69.     echo -n "Starting diald...            $CR"
  70.     if [ "$MODEM0" ]; then 
  71.         fork diald
  72.         [ "`echo $DRULES|sed 's/accept\ any\ //;s/\ any//'`" = 1 ] && control force >/dev/null && echo -n "${CR}Force "   
  73.         =
  74.     else 
  75.         echo "Error - MODEM0 is not configured.$CW"
  76.         return 2
  77.     fi
  78. }
  79.  
  80. case "$1" in
  81.     start)    str;;
  82.     stop)    stp;;
  83.     restart)stp;str;;
  84.     status)    if [ "`fn2`" ]
  85.             then echo "Running diald:"; fn2
  86.             else echo No running diald
  87.         fi;;
  88. esac
  89.  
  90.